#include <bits/stdc++.h>

using namespace std;

class FoodRatings
{
    unordered_map<string, pair<int, string>> foodMap;
    unordered_map<string, priority_queue<pair<int, string>, vector<pair<int, string>>, greater<>>> ratingMap;
    int n;

public:
    FoodRatings(vector<string> &foods, vector<string> &cuisines,
                vector<int> &ratings)
    {
        n = foods.size();
        for (int i = 0; i < n; ++i)
        {
            auto &food = foods[i], &cuisine = cuisines[i];
            int rating = ratings[i];
            foodMap[food] = {rating, cuisine};
            ratingMap[cuisine].emplace(-rating, food);
        }
    }

    void changeRating(string food, int newRating)
    {
        auto &[rating, cuisine] = foodMap[food];
        ratingMap[cuisine].emplace(-newRating, food);
        rating = newRating;
    }

    string highestRated(string cuisine)
    {
        auto &q = ratingMap[cuisine];
        auto &[rating, food] = q.top();
        while (-rating != foodMap[food].first)
        {
            q.pop();
        }
        return q.top().second;
    }
};

int main()
{

    // system("pause");
    return 0;
}
